const path = require("path");
const webpack = require("webpack");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const PreloadWebpackPlugin = require("./preload-webpack-plugin");
module.exports = {
  mode: "production",
  entry: {
    index: "./src/index.js",
  },
  context: process.cwd(),
  output: {
    path: path.resolve("dist"),
    filename: "[name].[chunkhash:8].js",
  },
  devServer: {
    port: 9999,
    static: path.resolve(__dirname, "public"),
    open: true,
  },
  plugins: [
    new webpack.ProgressPlugin(),
    new CleanWebpackPlugin(),

    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, "src/index.html"),
    }),
    new PreloadWebpackPlugin(),
  ],
};
